This invention relates to an encoding apparatus and an encoding method, and is applicable to the encoding of a video signal based on a format of the MPEG (moving picture experts group).
In a conventional encoding apparatus which performs encoding processing in accordance with the MPEG format, by switching the quantization step size or frequency characteristic of a prefilter in accordance with the amount of generated code, a video signal can be compressed and encoded at a desired bit rate.
In FIG. 2, a conventional encoding apparatus is illustrated by numeral 1. A digital video signal DV in a predetermined format is outputted to a prefilter 2. The prefilter 2 subjects the digital video signal DV to band limitation processing in accordance with a band limitation signal supplied from a rate control circuit 3 and transmits it to a pixel number converting circuit 4.
The pixel number converting circuit 4 thins out the digital video signal DV at intervals of a predetermined number of pixels so that the number of pixels of the digital video signal DV is converted to a pre-fixed number of pixels, and transmits it to a preprocessing circuit 5 of an encoding unit 19. The preprocessing circuit 5 first designates according to a predetermined sequence as which picture type it should process each frame image of the digital video signal DV with its converted number of pixels inputted sequentially in order of raster scan, among three picture types: I-(intra) picture, P-(predictive) picture, or B-(bi-directionally predictive) picture. Then, the preprocessing circuit 5 reorders the frame images in order of encoding according to the designated picture type, divides them into macroblocks which are composed of a luminance signal of 16 pixelsxc3x9716 lines and a color difference signal corresponding to the luminance signal, and then transmits them as image data per macroblock in order of block scan to a subtractor 6.
The subtractor 6 is supplied with predictive image data from a motion compensation circuit 7 in addition to the image data per macroblock from the preprocessing circuit 5. When the image data in macroblock is of I-picture, it is transmitted as it is to a DCT (discrete cosine transform) circuit 8. Or when the image data is of P-picture or B-picture, differential data between the image data and predictive image data is transmitted to the DCT circuit 8.
The DCT circuit 8 subjects the image data or the differential data supplied from the subtractor 6 to discrete cosine transform processing, and transmits the resultant coefficient data to a quantizing circuit 9. The quantizing circuit 9 quantizes the coefficient data supplied from the DCT circuit 8 in accordance with a quantization step size on a quantization table set by a rate circuit 3, and transmits it to a variable-length encoding circuit 10 and an inverse quantizing circuit 12.
The variable-length encoding circuit 10 variable-length-encodes the output data from the quantizing circuit 9 and transmits it as encoded data to a buffer 11. The buffer 11 once stores the encoded data therein and outputs it at a constant data transfer rate. The buffer 11 outputs the encoded data with a predetermined format along with the motion vector detected and coded by a motion vector detecting circuit 16, the quantization table of the quantizing circuit 9, and data on the picture type of image data designated by the preprocessing circuit 5. In the encoding apparatus 1, the output data from the buffer 11 is supplied as a video stream to, for example, a following multiplexing unit (not shown).
The inverse quantizing circuit 12 inverse-quantizes the output data from the quantizing circuit 9 so as to restore the original coefficient data inputted to the quantizing circuit 9 and transmits it to an inverse DCT circuit 13. The inverse DCT circuit 13 performs inverse discrete cosine transform on the output data from the inverse quantizing circuit 12 so as to restore the original image data inputted to the DCT circuit 8, and transmits it to an adder 14.
The adder 14 stores the image data from the inverse DCT circuit 13 directly into a frame memory 15 if the supplied data is of I-picture, and holds it as image data which is necessary for the prediction of such as P-picture which follows.
The adder 14 adds image data supplied from the inverse DCT circuit 13 and the predictive image data supplied from the motion compensation circuit 7 if the supplied data is of P-picture so as to restore the original image data inputted in the subtractor 6, and stores the restored image data in the frame memory 15.
The motion vector detecting circuit 16 detects the motion vector of image data supplied at every macroblock of P-picture or B-picture from the preprocessing circuit 5 according to, for example, a block matching algorithm, and transmits it to the motion compensation circuit 7. The motion compensation circuit 7 reads out image data from the frame memory 15 depending on a timing corresponding to the motion vector detected by the motion vector detecting circuit 16, and outputs the read image data as predictive image data to the subtractor 6.
The rate control circuit 3 constantly observes a vacant region in the buffer 11, controls the frequency characteristics of the prefilter 2 depending on the vacant region, rewrites the quantization table of the quantizing circuit 9 and controls the quantization step size. Furthermore, an en coding unit control circuit 18 sets the detecting range of the motion vector in the motion vector detecting circuit 16, and controls the operation timing of the entire encoding unit 19 indicated with a broken line.
In practice, when encoding the digital video signal DV with violent motion, the encoding apparatus 1 increases the band limitation amount of the prefilter 2 and enlarges the quantization step size of the quantizing circuit 9. In this way, encoding is performed almost with the same amount of generated code as that of the digital video signal DV with less motion.
With this configuration, the encoding apparatus 1 reduces, by increasing the band limitation amount in the prefilter 2 and enlarging the quantization step size in the quantizing circuit 9, the amount of code generated when the digital video signal DV with violent motion is encoded almost to the same amount as generated when the digital video signal DV with less motion is encoded. On the other hand, enlarging the quantization step size has extremely deteriorated the image quality because of worsened quantization.
The present invention has been made in view of the above, and thus the object of the invention is to provide an encoding apparatus and an encoding method that dramatically improve the image quality when encoding a video signal with violent motion, compared with the prior art.
In order to solve the above problem, there is provided an encoding apparatus for processing a video signal with a signal processing unit, producing coefficient data by an orthogonal transform of differential data obtained by motion compensation, generating coded data by quantization of the coefficient data and switching the quantization step size at the time of the quantization according to the amount of generated data of the coded data. The signal processing circuit comprises: a motion vector detecting means for detecting a motion vector of the video signal; a motion vector code amount detecting means for detecting the amount of code of the motion vector on the basis of the motion vector; a coefficient data code amount detecting means for detecting the amount of code of the coefficient data; and a pixel number converting means for converting the number of pixels of the video signal according to the amount of code of the motion vector and the amount of code of the coefficient data.
The present invention is also provided with an encoding method for processing a video signal by predetermined signal processing; producing coefficient data by an orthogonal transform of differential data obtained by motion compensation; generating coded data by quantization of the coefficient data and switching the quantization step size at the time of the quantization according to the amount of generated data of coded data. The signal processing comprises the steps of: detecting a motion vector of the video signal; detecting the amount of code of the motion vector based on the detected motion vector and detecting the amount of code of the coefficient data; and converting the number of pixels of the video signal on the basis of the amount of code of the motion vector and the amount of code of the coefficient data.
As described above, the number of pixels of the video signal is reduced at intervals of predetermined number of pixels on the basis of the amount of code of the motion vector and the code amount of the coefficient data. This makes it possible to reduce the number of pixels on an accurate judgement based on the amount of code of the motion vector and the amount of code of the coefficient data that the motion of the video signal is violent. As a result, a video signal with its number of pixels reduced has less amount of generated code so that the quantization step size is switched moderately and image quality deterioration can be avoided. Thus, it is possible to provide an encoding apparatus and an encoding method that dramatically improve the image quality compared with the prior art when encoding a video image with violent motion.